<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed!');

class Auth extends OC_Controller {

	function __construct()
	{
		parent::__construct(array(
			'login_check' => FALSE
		));
	}

	function _remap($method, $params = array())
	{
		parent::_remap($method, $params);

		if (method_exists($this, $method))
			return call_user_func_array(array($this, $method), $params);
		else
			show_404();
	}

	function init_header(){}

	function index()
	{
		redirect('dashboard');
	}

	function login()
	{
		$this->init_header();
		$this->view('auth/login_view', 'login');
	}

	function validate()
	{
		$username = $this->input->post('username');
		$password = $this->input->post('password');

		if ($this->bitauth->login($username, $password))
			redirect('dashboard');
		else
			redirect('auth/login');
	}

	function logout()
	{
		$this->bitauth->logout();
		redirect('auth/login');
	}

}